require(['jquery','cookie','app', 'lay'],function ($) {
    require(['vue'],function (Vue) {
        var dic=new Vue({
            el:".vue-box"
            ,data:{
                where:[],
                ADD:{
                    F_ROLE_CODE:"",
                    F_METHOD_TIME:""
                },
                th:{

                }
            }
            ,created:function () {
                this.loadPage();
                this.ADD.F_ROLE_CODE = "ROLE"+getCode(8);
                this.ADD.F_METHOD_TIME = getDete("ymd");
            }
            ,methods:{
                loadPage:function(){
                    var json = {};
                    json["APPID"]="550e8400-e29b-41d4-a716-446655440000";
                    json["uuid"]="1566381003875";
                    var re = playAjax("1574998957822",json);
                    var toolbar = [];
                    toolbar[0] = {
                        "clas": "",
                        "eve": "UPDATE",
                        "tit": "修改",
                        "fnc": function (data) {
                            if (data.length == 0) {
                                alr("请选中一行！");
                                return false;
                            } else {
                                dic.th=data[0];
                                $("html,body").animate({scrollTop: $(".layui-tab-content").offset().top}, 500);
                                layui.use(['element'], function () {
                                    var element = layui.element;
                                    element.tabChange('docDemoTabBrief', '2');
                                });
                                setTimeout(function () {
                                    layui.use(['element'], function () {
                                        var form = layui.form;
                                        form.render();
                                    })
                                },1500);
                            }
                        }
                    };
                    toolbar[1] = {
                        "clas": "",
                        "eve": "DATASQ",
                        "tit": "接口授权",
                        "fnc": function (data) {
                            if (data.length == 0) {
                                alr("请选中一行！");
                                return false;
                            } else {
                                layer.open({
                                    type: 2
                                    , content: "./vsp?code=1574998957826&F_ROLE_CODE="+data[0].F_ROLE_CODE+"&token=" + new acquire().parameterMap['token']
                                    , area: ["1000px", "500px"]
                                    , btn: ['确定', '取消']
                                    , yes: function (index, layero) {
                                        var body = layer.getChildFrame('body', index);
                                        var w = $(layero).find("iframe")[0].contentWindow;
                                        var jon = w.checkSure();
                                        if(jon!=false){
                                            var json = {};
                                            json['fspRole']=data[0];
                                            json['fspDataRecordList']=jon;
                                            var re = playAjax("1574998957826", json);
                                            alr(re['title']);
                                            if (re['code'] == '0') {
                                                setTimeout(function () {
                                                    dic.referXadmin();
                                                }, 500);
                                            }
                                            layer.closeAll();
                                        }
                                    }
                                    , btn2: function (index, layero) {
                                        layer.closeAll();
                                    }
                                    , cancel: function () {
                                        layer.closeAll();
                                    }
                                });
                            }
                        }
                    };
                    toolbar[2] = {
                        "clas": "",
                        "eve": "LOOKSQ",
                        "tit": "页面授权",
                        "fnc": function (data) {
                            if (data.length == 0) {
                                alr("请选中一行！");
                                return false;
                            } else {
                                layer.open({
                                    type: 2
                                    , content: "./vsp?code=1574998957827&F_ROLE_CODE="+data[0].F_ROLE_CODE+"&token=" + new acquire().parameterMap['token']
                                    , area: ["1000px", "500px"]
                                    , btn: ['确定', '取消']
                                    , yes: function (index, layero) {
                                        var body = layer.getChildFrame('body', index);
                                        var w = $(layero).find("iframe")[0].contentWindow;
                                        var jon = w.checkSure();
                                        if(jon!=false){
                                            var json = {};
                                            json['fspRole']=data[0];
                                            json['fspLookRecordList']=jon;
                                            var re = playAjax("1574998957827", json);
                                            alr(re['title']);
                                            if (re['code'] == '0') {
                                                setTimeout(function () {
                                                    dic.referXadmin();
                                                }, 500);
                                            }
                                            layer.closeAll();
                                        }
                                    }
                                    , btn2: function (index, layero) {
                                        layer.closeAll();
                                    }
                                    , cancel: function () {
                                        layer.closeAll();
                                    }
                                });
                            }
                        }
                    };
                    toolbar[3] = {
                        "clas": "",
                        "eve": "NAVIGSQ",
                        "tit": "导航授权",
                        "fnc": function (data) {
                            debugger;
                            if (data.length == 0) {
                                alr("请选中一行！");
                                return false;
                            } else {
                                layer.open({
                                    type: 2
                                    , content: "./vsp?code=1574998957828&F_ROLE_CODE="+data[0].F_ROLE_CODE+"&token=" + new acquire().parameterMap['token']
                                    , area: ["1000px", "500px"]
                                    , btn: ['确定', '取消']
                                    , yes: function (index, layero) {
                                        var body = layer.getChildFrame('body', index);
                                        var w = $(layero).find("iframe")[0].contentWindow;
                                        var jon = w.checkSure();
                                        if(jon!=false){
                                            var json = {};
                                            json['fspRole']=data[0];
                                            json['fspNavigationList']=jon;
                                            var re = playAjax("1574998957828", json);
                                            alr(re['title']);
                                            if (re['code'] == '0') {
                                                setTimeout(function () {
                                                    dic.referXadmin();
                                                }, 500);
                                            }
                                            layer.closeAll();
                                        }
                                    }
                                    , btn2: function (index, layero) {
                                        layer.closeAll();
                                    }
                                    , cancel: function () {
                                        layer.closeAll();
                                    }
                                });
                            }
                        }
                    };
                    if(re.code=='0'){
                        bspVIEW($(".sa-table"),"1566381003876",JSON.parse(re.data),this.where,toolbar);
                    }
                },
                referXadmin: function () {
                    window.location.reload();
                },
                seachs:function () {
                    this.where=whereJSON($(".el-form"));
                    this.loadPage();
                },
                editDBL: function (e) {
                    var e = e.target;
                    $(e).html("<input class='layui-input' onblur='editBlur(this)'/>");
                },
                editDBLTEXT: function (e) {
                    var e = e.target;
                    $(e).html("<textarea class='layui-textarea' onblur='editBlur(this)'></textarea>");
                },
                ADD_SAVE: function () {
                    var jon = {};
                    jon = fromName($("#add_save"));
                    if (jon['F_ROLE_NAME'] == "" || jon['F_ROLE_NAME'] == null) {
                        alr("请双击输入角色名!");
                        return;
                    } else {
                        var re = playAjax("1574998957825", jon);
                        alr(re['title']);
                        dic.referXadmin();
                    }
                },
                UPDATE_SAVE: function () {
                    var jon = {};
                    jon = fromName($("#update_save"));
                    if (jon['F_ROLE_NAME'] == "" || jon['F_ROLE_NAME'] == null) {
                        alr("请双击输入角色名!");
                        return;
                    } else {
                        jon['uuid'] = this.th['UUID'];
                        var re = playAjax("1574998957825", jon);
                        alr(re['title']);
                        dic.referXadmin();
                    }
                },
            }
        })
    })

});
